package Service;

import DAO.OrderManageDao;
import Entities.OrderServiceListEntity;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

public class OrderManageService {
    public final static String CANCELED = "order canceled";
    public final static String CHANGED = "order changed";
    public final static String STATUS_SUCCESS = "success";
    public final static String STATUS_FAIL = "fail";

    private OrderManageDao manageDao;

    public OrderManageDao getManageDao() {
        return manageDao;
    }

    public void setManageDao(OrderManageDao manageDao) {
        this.manageDao = manageDao;
    }

    public String addOrderManage(Map<String ,String > params){
        String purchaseNo = params.get("purchaseNo");
        String service_type = params.get("service_type");
        String service_detail = params.get("service_detail");
        String user_name= params.get("user_name");
        OrderServiceListEntity serviceListEntity = new OrderServiceListEntity();
        serviceListEntity.setPurchaseNo(purchaseNo);
        serviceListEntity.setUserName(user_name);
        serviceListEntity.setServiceType(service_type);
        serviceListEntity.setServiceDetail(service_detail);
        serviceListEntity.setServiceDate(new Date(System.currentTimeMillis()));
        boolean flag = manageDao.addOrderManage(serviceListEntity);
        if (flag)
            return STATUS_SUCCESS;
        else
            return STATUS_FAIL;
    }

    public List queryOrderManage(String userName){
        return manageDao.queryManageList(userName);
    }



}
